<template>
  <div ref="BarECharts" style="width: 100%;height: 100%"></div>
</template>

<script setup>
import {nextTick, onMounted, ref} from "vue";
import * as echarts from 'echarts';

const BarECharts = ref(null)

onMounted(() => {
  nextTick(() => {
    init()
  })
})

const init = () => {
  if (BarECharts.value) {
    const Echarts = echarts.init(BarECharts.value);
    const option = {
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      xAxis: {
        type: 'category',
        data: ['2019', '2020', '2021', '2022', '2024', '2024']
      },
      yAxis: {
        type: 'value',
        splitLine: {
          show: false
        }
      },
      grid: {
        top: '10',
        left: '30',
        right: '30',
        bottom: '10',
        containLabel: true
      },
      series: [
        {
          data: ['2.11', '3.59', '1.76', '2.23', '3'],
          type: 'bar',
          barWidth: 30,
          showBackground: true,
          backgroundStyle: {
            color: 'rgba(180, 180, 180, 0.2)'
          },
          itemStyle: {
            normal: {
              color: '#528dff',
            },
          },
        },
        {
          type:'line',
          itemStyle:{
            opacity:0
          },
          lineStyle:{
            width:2,
            color:'#73deb3'
          },
          data: ['2.11', '3.59', '1.76', '2.23', '3'],
        }
      ]
    };
    Echarts.setOption(option);
    window.onresize = Echarts.resize
  }
}


</script>

<style lang="less" scoped>
</style>
